package com.zjw.zy.aidl.impl;

import android.os.RemoteException;

import com.zjw.zy.aidl.binder.IAppServiceBinder;
import com.zjw.zy.bean.Tip;
import com.zjw.zy.bean.User;
import com.zjw.zy.bean.WsMessage;
import com.zjw.zy.service.helper.CloudHelper;
import com.zjw.zy.service.helper.TipsHelper;
import com.zjw.zy.service.helper.UserHelper;
import com.zjw.zy.service.helper.VoiceHelper;
import com.zjw.zy.service.helper.WbSocketHelper;
import com.zjw.zy.service.helper.WeatherHelper;
import com.zjw.zy.smi.JustWithIt;
import com.zjw.zy.utils.LogUtils;
import com.zjw.zy.utils.TimeUtils;

import remotecall.call.IRemoteCall;

public class AppServiceBinder extends IAppServiceBinder.Stub {

    private static final String TAG = "AppServiceBinder";

    @Override
    public void request15DayWeather(IRemoteCall call) {
        WeatherHelper.getInstance().request15DayWeather(obj -> {
            call.call(obj);
        });
    }

    @Override
    public void request1DayWeather(IRemoteCall call) {
        WeatherHelper.getInstance().request1DayWeather(call);
    }

    @Override
    public void observerNearWeather(IRemoteCall call) {
        WeatherHelper.getInstance().observerNearWeather(call);
    }

    @Override
    @SuppressWarnings("unchecked")
    public void removeNearWeather(IRemoteCall call) {
        WeatherHelper.getInstance().removeNearWeather(call);
    }


    @Override
    public void observer1DayWeather(IRemoteCall call) {
        WeatherHelper.getInstance().observer1DayWeather(call);
    }

    @Override
    @SuppressWarnings("unchecked")
    public void remove1DayWeather(IRemoteCall call) {
        WeatherHelper.getInstance().remove1DayWeather(call);
    }

    @Override
    public void requestVoiceToText(String path, IRemoteCall call) {
        VoiceHelper.getInstance().requestVoiceToText(path, call);
    }

    @Override
    public void requestAppUIMode(IRemoteCall call) {
        CloudHelper.getInstance().requestUiMode(call::call);
    }

    @Override
    public void addDayScheduler(TimeUtils.TimeBean timeBean, IRemoteCall call) {
        TimeUtils.addDayScheduler(timeBean, () -> call.call(timeBean));
    }

    @Override
    public void addSchedulerForTips(Tip tip) {
        TipsHelper.addSchedulerForTips(tip);
    }

    @Override
    public void registerMessageObserver(IRemoteCall call) {
        WbSocketHelper.getInstance().registerMessageObserver(call);
    }

    @Override
    public void unregisterMessageObserver(IRemoteCall call) {
        WbSocketHelper.getInstance().unregisterMessageObserver(call);
    }

    @Override
    public void sendWsMessage(WsMessage message) {
        WbSocketHelper.getInstance().sendMessage(message);
    }

    @Override
    public void registerAccess(User user, IRemoteCall call) {
        UserHelper.getInstance().registerAccess(user, call::call);
    }

    @Override
    public void requestLover(User user, IRemoteCall call) {
        UserHelper.getInstance().queryLover(user, call::call);
    }

    @Override
    public void connectService() {
        WbSocketHelper.getInstance().connectService(obj -> LogUtils.d(TAG, "connect result:" + obj));
    }
}
